<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
   <script>
    //matchAll 需要全局匹配(g),返回一个迭代器接口
    //匹配电话号码
    var str = 'gfdg13411112222fdgdg18944445555'
    //?<别名>  捕获组命名
    var reg = /(?<first>1[2-9])\d{9}/g
    var result = [...str.matchAll(reg)]
    // console.log(result)
    // // for(var item of result ){
    // //     console.log(item)
    // // }
    // console.log(...result)
    
//     result.forEach((item) => {
//     let {first} =item.groups
//     console.log(first)
//    });
  for(var item of result ){
       let {first} = item.groups
       console.log(first)
    }
   

    //非捕获组，（）用作一个整体，并不需要反向引用，
    //邮箱正则
    var reg = /\w+@(?:[0-9a-z]+\.)+[a-z]{2}/gi
    console.log(reg.test('634563456@qq.com'))
   </script> 
</body>
</html>